/*
 * @Author: your name
 * @Date: 2020-09-01 14:38:59
 * @LastEditTime: 2020-09-01 15:21:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /express/src/decorator/request.ts
 */
import { CrowllerController, LoginController } from '../controller';

// 枚举
export enum Methods {
  get = 'get',
  post = 'post',
  put = 'put',
  delete = 'delete'
}

function getRequestDecorator(type: Methods) {
  return function(path: string) {
    return function(target: CrowllerController | LoginController, key: string) {
      Reflect.defineMetadata('path', path, target, key);
      Reflect.defineMetadata('method', type, target, key);
    };
  };
}

export const get = getRequestDecorator(Methods.get);
export const post = getRequestDecorator(Methods.post);
export const put = getRequestDecorator(Methods.put);
export const del = getRequestDecorator(Methods.delete);
